$OpenBSD: patch-src_webserver_src_WebServer_cpp,v 1.1 2012/02/22 07:54:26 dcoppa Exp $

Fix amuleweb crash on CProgressImage::CreateSpan
(upstream git commit 846dcf92ce64fd42caf8a86d644fe3a3f4683d09)

--- src/webserver/src/WebServer.cpp.orig	Mon Jun 13 10:50:25 2011
+++ src/webserver/src/WebServer.cpp	Tue Feb 21 15:54:36 2012
@@ -1064,18 +1064,24 @@ void CProgressImage::CreateSpan()
 		}
 	} else {
 		uint32 factor = m_file->lFileSize / m_width;
-		for(int i = 1; i <= colored_gaps_size;i++) {
+		for (int i = 1; i <= colored_gaps_size;i++) {
 			uint32 start = colored_gaps[i].start / factor;
 			uint32 end = colored_gaps[i].end / factor;
-			for(uint32 j = start; j < end; j++) {
+			if ((int)end > m_width) {
+				end = m_width;
+			}
+			for (uint32 j = start; j < end; j++) {
 				m_ColorLine[j] = colored_gaps[i].color;
 			}
 		}
 		// overwrite requested parts
-		for(uint32 i = 0; i < m_file->m_ReqParts.size(); i++) {
+		for (uint32 i = 0; i < m_file->m_ReqParts.size(); i++) {
 			uint32 start = m_file->m_ReqParts[i].start / factor;
 			uint32 end = m_file->m_ReqParts[i].end / factor;
-			for(uint32 j = start; j < end; j++) {
+			if ((int)end > m_width) {
+				end = m_width;
+			}
+			for (uint32 j = start; j < end; j++) {
 				m_ColorLine[j] = RGB(255, 208, 0);
 			}
 		}
